package org.kardigen.lg.admin.client.training;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.Widget;

public class TrainingsView extends Composite implements TrainingsViewDisplay {

	interface Binder extends UiBinder<Widget, TrainingsView> {
		Binder BINDER = GWT.create(Binder.class);
	}

	public TrainingsView() {
		initWidget(Binder.BINDER.createAndBindUi(this));
	}

	@UiField
	Tree traingsTree;

	private Presenter presenter;

	public Tree getTraingsTree() {
		return traingsTree;
	}

	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;
	}

	@UiHandler("traingsTree")
	public void onTreeSelectionAction(SelectionEvent<TreeItem> event) {
		presenter.onTreeSelectionAction(event.getSelectedItem());
	}

}
